<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>地图找房</title>
    <link rel="stylesheet" th:href="@{/airent/plugins/bootstrap/bootstrap-4.4.1-dist/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/airent/common/css/nav.css}">
    <link rel="stylesheet" th:href="@{/airent/css/index.css}">
    <link rel="stylesheet" th:href="@{/airent/css/searchmap.css}">
    <link rel="stylesheet" th:href="@{/airent/plugins/other/animate.min.css}" />
    <link rel="icon" th:href="@{/airent/common/imgs/icon.ico}" type="images/x-ico" />
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
    <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=2gQBx0YMMZFbGo0j9HkQ4CncLx1rrFzD"></script>
    <script src="http://api.map.baidu.com/library/GeoUtils/1.2/src/GeoUtils.js"></script>
    <script src="http://api.map.baidu.com/library/InfoBox/1.2/src/InfoBox_min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=2gQBx0YMMZFbGo0j9HkQ4CncLx1rrFzD"></script>
    <script type="text/javascript" th:src="@{/airent/js/jquery-3.5.1.js}"></script>

</head>

<body>
<!-- 导航栏 - 开始 -->
<div th:replace="~{head/topbar::topBar(activeUri = 'rent')}"></div>
<!-- 导航栏 - 结束 -->

<!-- 地图找房 - 开始 -->

<div class="search-up">
    <div class="findhouse">
        <div class="search-box" >
            <div class="input-group">
                <input type="text" class="form-control" id="areaName" name="areaName" th:value="${areaName}" placeholder="输入小区名" aria-label="Recipient's username" aria-describedby="basic-addon2">
            </div>
        </div>

        <div class="fottler">
            <div class="btn-group">
                <button class="btn btn-secondary btn-sm dropdown-toggle lianjiean" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    房租
                </button>
                <div class="dropdown-menu" style="padding-left: 10px;">
                    <div class="form-check">
                        <input type="radio" name="money" value="1-1000" class="form-check-input" id="moneyCheckOne" >
                        <label class="form-check-label"  for="moneyCheckOne" >
                            1000以下
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="1000-2000" class="form-check-input" id="moneyCheckTow" >
                        <label class="form-check-label"  for="moneyCheckTow" >
                            1000-2000
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="2000-3000" class="form-check-input" id="moneyCheckThree" >
                        <label class="form-check-label"  for="moneyCheckThree" >
                            2000-3000
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="3000-4000" class="form-check-input" id="moneyCheckFive" >
                        <label class="form-check-label"  for="moneyCheckFive" >
                            3000-4000
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="4000-5000" class="form-check-input" id="moneyCheckSix" >
                        <label class="form-check-label"  for="moneyCheckSix" >
                            4000-5000
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="money" value="5000-20000" class="form-check-input" id="moneyCheckSeven" >
                        <label class="form-check-label"  for="moneyCheckSeven" >
                            5000以上
                        </label>
                    </div>
                </div>
            </div>

            <div class="btn-group">
                <button class="btn btn-secondary btn-sm dropdown-toggle lianjiean" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    房型
                </button>
                <div class="dropdown-menu" style="padding-left: 10px;">

                    <div class="form-check">
                        <input type="radio" name="house" value="一室" class="form-check-input" id="houseCheckTwo" >
                        <label class="form-check-label"  for="houseCheckTwo" >
                            一室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house" value="二室" class="form-check-input" id="houseCheckThree" >
                        <label class="form-check-label"  for="houseCheckThree" >
                            二室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house" value="三室" class="form-check-input" id="houseCheckFour" >
                        <label class="form-check-label"  for="houseCheckFour" >
                            三室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house"  value="四室" class="form-check-input" id="houseCheckFive" >
                        <label class="form-check-label"  for="houseCheckFive" >
                            四室
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="house" value="五室" class="form-check-input" id="houseCheckSix" >
                        <label class="form-check-label"  for="houseCheckSix" >
                            五室
                        </label>
                    </div>
                </div>
            </div>

            <div class="btn-group">
                <button class="btn btn-secondary btn-sm dropdown-toggle lianjiean" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    面积
                </button>
                <div class="dropdown-menu" style="padding-left: 10px;">
                    <div class="form-check">
                        <input type="radio" name="area" value="1-50" class="form-check-input" id="areaCheckOne" >
                        <label class="form-check-label"  for="areaCheckOne" >
                            50平以下
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="50-70" class="form-check-input" id="areaCheckTwo" >
                        <label class="form-check-label"  for="areaCheckTwo" >
                            50-70平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="70-90" class="form-check-input" id="areaCheckThree" >
                        <label class="form-check-label"  for="areaCheckThree" >
                            70-90平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="90-120" class="form-check-input" id="areaCheckFive" >
                        <label class="form-check-label"  for="areaCheckFive" >
                            90-120平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="120-150" class="form-check-input" id="areaCheckSix" >
                        <label class="form-check-label"  for="areaCheckSix" >
                            120-150平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="150-200" class="form-check-input" id="areaCheckSeven" >
                        <label class="form-check-label"  for="areaCheckSeven" >
                            150-200平
                        </label>
                    </div>
                    <div class="form-check">
                        <input type="radio" name="area" value="200-10000" class="form-check-input" id="areaCheckEight" >
                        <label class="form-check-label"  for="areaCheckEight" >
                            200平以上
                        </label>
                    </div>
                </div>
            </div>
        </div>

        <div class="input-group-append">
            <button class="btn btn-outline-secondary" type="button" onclick="areaCheck()">搜索</button>
        </div>
    </div>

</div>

<div class="houseresult">
<div></div>
    <div class="col-md-11" th:each="h:${houses}">
        <div class="housemaptu" th:onclick="|goDetail(${h.houseId})|">
            <img th:src="@{'https://airent-1303816068.cos.ap-shanghai.myqcloud.com/'+${h.imgs[0].imgAdress}}">
            <div class="housemapturi">
                <h4 th:text="${h.houseResource}">无中介费，直租</h4>
                <span th:text="${h.houseType}"></span><br>
                <span th:text="${h.houseCity}"></span>
               <span th:text="${h.houseArea}"></span>
                <span th:utext="${h.houseMeasure}">^m</span><br>
                <div class="redprice">
                    <div style="float: left; font-size: 10px; color: #666675;" th:text="${h.villageName}"></div>
                    <div style="float: right; color: red;"><strong th:text="${h.rentPrice}">900元/月</strong><span>元/月</span></div>
                </div>
            </div>
        </div>
    </div>

</div>

<div class="map">
    <div id="allmap"></div>
    <div id="r-result"></div>
</div>
<script type="text/javascript" th:src="@{/airent/js/jquery-3.5.1.js}"></script>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");

    var point = new BMap.Point(121,31);
    map.centerAndZoom(point,12);
    map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用

    $(function(){
        var areaName=$("#areaName").val();
        //alert(areaName);
        var local = new BMap.LocalSearch(map, {
            renderOptions: {map: map, panel: "r-result"}
        });
        local.search(areaName);

    });


    //按地区搜索
    function areaCheck(){
        var areaName=$("#areaName").val();
        //alert(areaName);
        var local = new BMap.LocalSearch(map, {
            renderOptions: {map: map, panel: "r-result"}
        });
        local.search(areaName);

        var money='';

        $("input[name='money']:checked").each(function (i) {
            money+=($(this).val()+",");
        });
       // alert(money);

        var house='';
        $("input[name='house']:checked").each(function (i) {
            house+=($(this).val()+",");
        });
       // alert(house);

        var area='';
        $("input[name='area']:checked").each(function (i) {
            area+=($(this).val()+",");
        });
        //alert(area);


        window.location.href="/map/areaCheck?areaName="+areaName+"&money="+money+"&house="+house+"&area="+area;
        /*$.ajax({
            type:"POST",
            url:"/map/areaCheck",
            dataType:"json",
            data:{
                "areaName":areaName,
                "money":money,
                "house":house,
                "area":area
            },
            success:function(data){

            }
        })*/

    }

    function goDetail(hid) {
        location.href="/houseUser/detail?houseId="+hid;
    }


</script>




<!-- 地图找房 - 结束 -->

<script th:src="@{/airent/plugins/jquery/jquery.min.js}"></script>
<script th:src="@{/airent/plugins/bootstrap/bootstrap-4.4.1-dist/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/airent/plugins/bootstrap/bootstrap-4.4.1-dist/js/bootstrap.min.js}"></script>

</body>
</html>
